// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import SpriteGraphics from "./SpriteGraphics";

const { ccclass, property } = cc._decorator;

@ccclass
export default class LineRender extends cc.Component {
    @property(SpriteGraphics)
    line: SpriteGraphics = null;

    @property(cc.Graphics)
    graphics: cc.Graphics = null;

    protected onLoad(): void {
        // cc.log(cc.renderer["device"]);
        // let gl = cc.renderer["device"]["_gl"];
        // cc.log(gl);
        // gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
    }

    protected start(): void {
        let hw = cc.winSize.width * 0.5;
        let hh = cc.winSize.height * 0.5;
        // this.line.moveTo(-.5 * hw, 0);
        // this.line.lineTo(300, 0);
        // this.line.lineTo(0, 150);
        // this.line.lineTo(150, 150);
        let cLen = 0.55228;
        let r = 150;
        this.line.moveTo(r, 0);
        this.line.lineTo(0, 0);
        this.line.lineTo(0, 0.5 * r);
        // this.line.bezierCurveTo(r, r * cLen, r * cLen, r, 0, r);
        // this.line.bezierCurveTo(-r * cLen, r, -r, r * cLen, -r, 0);
        // this.line.bezierCurveTo(-r, -r * cLen, -r * cLen, -r, 0, -r);
        // this.line.bezierCurveTo(r * cLen, -r, r, -r * cLen, r, 0);
        this.line.stroke();
        // this.line.en

        // this.graphics.moveTo(-100, 0);
        // this.graphics.lineTo(100, 0);
        // this.graphics.lineTo(-100, 50);
        // this.graphics.bezierCurveTo(-hw * 0.5, 0, hw * 0.5, 0, hw, hh);
        // this.graphics.stroke();
    }

    protected update(dt: number): void {
        // cc.log(cc["math"].pseudoRandomRangeInt(cc.sys.now(),0,10000000000));
    }
}
